package com.le.tester.book.concurrentbattlechinese.sixtwoone;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;

/**
 * createTime：2022/8/3 17:59
 * description：线程池处理task
 */
public class TaskExecutionWebServer {
    private static final int NTHREADS = 100;

    private static final Executor EXECUTOR = Executors.newFixedThreadPool(NTHREADS);

    public static void main(String[] args) throws IOException {
        ServerSocket serverSocket = new ServerSocket(80);
        while (true) {
            Socket connection = serverSocket.accept();
            Runnable task = () -> {

                System.out.println("task");
                //handleRequest(connection);
            };
            EXECUTOR.execute(task);
        }
    }
}
